home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10952 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: news.iadfw.net!usenet
  2. From: Mark Nelson <markn@airmail.net>
  3. Newsgroups: comp.programming,comp.lang.c
  4. Subject: Re: need help with serial communication using c++
  5. Date: Wed, 20 Mar 1996 21:21:12 -0600
  6. Organization: customer of Internet America
  7. Message-ID: <3150CB28.1CE3@airmail.net>
  8. References: <DoLBFr.Hvp@seas.ucla.edu>
  9. NNTP-Posting-Host: dal17-30.ppp.iadfw.net
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0GoldB1 (Win95; I)
  14.  
  15. Daniel D Shin wrote:
  16. > Can someone out there help me how to write serial communication program using c language?  Specifically, I need to translate a qbasic program into c.  The basi
  17. >       OPEN "COM1:9600,e,7,1,CS,DS" FOR RANDOM AS #1
  18. >       PRINT #1, "CH",cn
  19. >       INPUT #1, dummy
  20. >       CLOSE #1
  21. > The program must run under DOS environment.
  22. > Thank you for your time, and any help would be greatly appreciated.
  23. > shin@seas.ucla.edu
  24.  
  25. Microsoft put serial drivers in their versions of BASIC, which was
  26. a nice thing to do.  Then, they pretty much left them out of the
  27. O/S, which wasn't nice.  So you really can't do a direct translation 
  28. of this QBASIC code into C or C++.  (Note: they put the serial drivers
  29. into MS Windows, so you can do this translation, sort of.  The rest
  30. of this message applies to MS-DOS only.)
  31.  
  32. To talk to the serial ports, particularly for input, you are going to
  33. need a set of routines that perform interrupt driven communications.
  34. You can buy a commercial library, find a shareware library, or just
  35. pull some code into your program.
  36.  
  37. If you just want some simple code to add to your program, you can find
  38. it accompanying a magazine article on my home page.  Follow the links
  39. to Articles and look for "Servicing COM Port Interrupts", which ran
  40. in 1990.
  41.  
  42. If you want to know more, there is at least one other article on serial
  43. communications there.  You can also follow the links to my book, "Serial
  44. Communications: A C++ Developer's Guide," if you want more depth.
  45.  
  46. Mark Nelson
  47. http://web2.airmail.net/markn
  48.